package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.service.RefundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/message")
public class MessageController {
    @Autowired
    RefundService refundService;

    // 查询所有的退款请求
    @RequestMapping("listRefund")
    public JsonResult listRefund(){
        return refundService.listRefundAndOrder();
    }


    // 同意当前的退款请求
    @RequestMapping("acceptRefund")
    public JsonResult acceptRefund(@RequestParam(value = "id") Integer id) {
        refundService.acceptRefund(id);
        return new JsonResult(0, "", true);
    }

    // 拒绝当前的退款请求
    @RequestMapping("refuseRefund")
    public JsonResult refuseRefund(@RequestParam(value = "id") Integer id) {
        refundService.refuseRefund(id);
        return new JsonResult(0, "", true);
    }
}
